﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace frmViewItemCatalog
{
    public class ItemCatalog
    {
        private List<ItemClass> listOfItem = new List<ItemClass>();


        public List<ItemClass> ListOfItem
        {
            get { return listOfItem; }
            set { listOfItem = value; }
        }


        public void Add(ItemClass item)
        {
            bool duplicateitem = false;

            foreach (ItemClass current in listOfItem)
            {
                if (current.CategoryName == item.CategoryName  && current.ItemName == item.ItemName)
                {
                    current.OrderQuantity  += item.OrderQuantity;
                    duplicateitem = true;
                    break;
                }
            }

            if (!duplicateitem)
            {
                listOfItem.Add(item);
            }

        }
    }
}